/**
 * @param { import("knex").Knex } knex
 * @returns { Promise<void> }
 */
exports.up = function(knex) {
  return knex.schema.createTable('tasks', function(table) {
    table.increments('id').primary()
    table.string('title').notNullable()
    table.text('description')
    table.boolean('completed').defaultTo(false)
    table.integer('user_id').unsigned().references('id').inTable('users').onDelete('CASCADE')
    table.timestamp('due_date')
    table.enum('priority', ['low', 'medium', 'high']).defaultTo('medium')
    table.timestamps(true, true)
  })
}

/**
 * @param { import("knex").Knex } knex
 * @returns { Promise<void> }
 */
exports.down = function(knex) {
  return knex.schema.dropTable('tasks')
}